var QUERY_URL="http://localhost:8080/users/queryall/";
var DELETE_URL="http://localhost:8080/card/del/";
$(function () {
   
    show();
  
});
function show() {//展示 用户的时候如果权限 不能显示信息
    var role=$.cookie("role");
    $.ajax({
        url:QUERY_URL,//+role
        type:"post",
        dataType:"json",
        statusCode:{
            200:function (data) {
                if(role!='cardAdministrator'){
                    window.location="role.html";//可以换成一张图片
            }
                $(data).each(function (index) {
                    var id=$("#list>tbody>tr:last").attr("id");
                    id++;
                    var str="<tr id='"+id+"' height='40' bgcolor='#FFFF88'>"+
                        "<td align='center' valign='middle' class='borderright borderbottom'>"+id+"</td>"+
                        "<td align='center' valign='middle' class='borderright borderbottom'>"+data[index].userno+"</td>"+
                        "<td align='center' valign='middle' class='borderright borderbottom'>"+data[index].username+"</td>"+
                        "<td align='center' valign='middle' class='borderright borderbottom'>"+data[index].role+"</td>"+
                        "<td align='center' valign='middle' class='borderright borderbottom'>"+data[index].datatime+"</td>"+
                        "<td align='center' valign='middle' class='borderbottom'>" +
                        "<a href='main_info.html' target='mainFrame' onFocus='this.blur()' class='add'>编辑</a><span class='gray'>&nbsp;|&nbsp;</span>" +
                        "<a href='#'  onclick='del("+data[index].userno+")' >删除</a>"+"</td>"+
                        "</tr>";
                    $("#list").append(str);
                })
            }
        }
    })
}
function del(userno) {
    $.ajax({
        url:DELETE_URL+userno,
        type:"DELETE",
        statusCode:{
            200:function () {
                window.location="main_list.html";
            }
        }
    })
}
